home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / gfa / crypt / crypt.gfa (.txt) next >
Encoding:
GFA-BASIC Atari  |  1996-02-10  |  1.1 KB  |  54 lines

  1. OPTION BASE 0
  2. DIM repere#(255,255)
  3. PRINT "Initialisation"
  4. IF EXIST("donnees.dat")
  5.   BLOAD "donnees.dat",VARPTR(repere#(0,0))
  6. ELSE
  7.   FOR i%=0 TO 255
  8.     FOR j%=0 TO 255
  9.       repere#(i%,j%)=(j%+i%) MOD 255
  10.     NEXT j%
  11.   NEXT i%
  12.   PRINT "ok!"
  13.   adr%=VARPTR(repere#(0,0))
  14.   BSAVE "donnees.dat",adr%,VARPTR(repere#(255,255))-adr%
  15. ENDIF
  16. '
  17. PRINT
  18. INPUT "Entrer le message … crypter :",txt$
  19. INPUT "Entrer votre cl‚ de cryptage:",cle$
  20. PRINT
  21. '
  22. PRINT "Cryptage..."
  23. txt%=LEN(txt$)
  24. cle%=LEN(cle$)
  25. FOR i%=1 TO INT(txt%/cle%)+1
  26.   code$=code$+cle$
  27. NEXT i%
  28. code$=LEFT$(code$,txt%)
  29. '
  30. '
  31. result$=""
  32. FOR i%=1 TO txt%
  33.   a#=ASC(MID$(txt$,i%))
  34.   b#=ASC(MID$(code$,i%))
  35.   result$=result$+CHR$(repere#(a#,b#))
  36. NEXT i%
  37. '
  38. PRINT "pPhrase crypt‚e :";result$+"q"
  39. '
  40. '
  41. PRINT
  42. PRINT "D‚cryptage..."
  43. txt2$=""
  44. FOR i%=1 TO LEN(result$)
  45.   a#=ASC(MID$(result$,i%))
  46.   b#=ASC(MID$(code$,i%))
  47.   txt2$=txt2$+CHR$(a#-b#)
  48. NEXT i%
  49. PRINT "pPhrase d‚crypt‚e :";txt2$+"q"
  50. PRINT
  51. '
  52. PRINT "Pressez une touche pour sortir."
  53. ~INP(2)
  54.